<template>
  <!-- 提货单修改 -->
  <div
    class="billOrder_styl"
    v-if="modalShow"
  >
    <Modal
      ref="modalEle"
      v-model="modalShow"
      width="500"
      class="modal-styl"
      :mask-closable="false"
    >
      <p
        slot="header"
        style="text-align: center"
      >
        <span>车辆信息</span>
      </p>
      <Form
        ref="formEle"
        :footer-hide="true"
        :model="addFather"
        :rules="ruleValidate"
        :label-width="80"
        style="width: 350px; margin: 0 auto"
      >
        <FormItem
          label="车牌号"
          prop="carNumber"
        >
          <Input
            v-model="addFather.carNumber"
            placeholder="请输入车牌号"
            readonly
          ></Input>
        </FormItem>
        <FormItem
          label="司机姓名"
          prop="carName"
        >
          <Input
            v-model="addFather.carName"
            placeholder="请输入司机姓名"
          ></Input>
        </FormItem>
        <FormItem
          label="身份证号"
          prop="carCard"
        >
          <Input
            v-model="addFather.carCard"
            placeholder="请输入身份证号"
          ></Input>
        </FormItem>
        <FormItem
          label="手机号码"
          prop="phone"
        >
          <Input
            v-model="addFather.phone"
            placeholder="请输入手机号码"
          ></Input>
        </FormItem>
      </Form>
      <div slot="footer">
        <Button
          type="text"
          @click="modalShow = false"
        >取消</Button>
        <Button
          :loading="btnLoading"
          type="primary"
          @click="submitFun"
        >确定</Button>
      </div>
    </Modal>
  </div>
</template>

<script>
import { validateIdCard, validatePhone, validateCarNo, } from "@/tool/myValidator";

export default {
  components: {},
  data() {
    return {
      ruleValidate: {
        carName: [{ required: true, message: "请输入司机姓名", type: "string", trigger: "blur", }],
        carCard: [{ required: true, validator: validateIdCard }],
        phone: [{ required: true, validator: validatePhone }],
        carNumber: [{ required: true, validator: validateCarNo }],
      },
      addFather: {},
      btnLoading: false,
      modalShow: false,
      columns: [
        {
          title: "订单编号",
          key: "billNo",
          align: "center",
          tooltip: true,
          minWidth: 240
        },
        {
          title: "状态",
          key: "status",
          slot: "status",
          align: "center",
          minWidth: 120
        },
        {
          title: "车牌号",
          key: "carNumber",
          align: "center",
          minWidth: 120
        },
        {
          title: "司机姓名",
          key: "carName",
          align: "center",
          minWidth: 100
        },
        {
          title: "司机身份证号",
          key: "carCard",
          align: "center",
          width: 180
        },
        {
          title: "司机电话",
          key: "phone",
          align: "center",
          width: 140
        },
        {
          title: "预装量",
          key: "num",
          align: "center",
          width: 120
        },
        {
          title: "实装量",
          key: "netWeight",
          align: "center",
          width: 120
        },
        // {
        //     title: "皮重",
        //     key: "address3",
        //     align: "center",
        //     width: 120
        // },
        // {
        //     title: "毛重",
        //     key: "address4",
        //     align: "center",
        //     width: 120
        // },
        // {
        //     title: "单价",
        //     key: "address5",
        //     align: "center",
        //     width: 120
        // },
        {
          title: "操作",
          slot: "action",
          align: "center",
          width: 120,
          fixed: "right"
        }
      ],
    };
  },
  mounted() {
  },
  methods: {
    openFun(item) {
      this.addFather = {
        id: item.id,
        carNumber: item.carNumber,
        carName: item.carName,
        carCard: item.carCard,
        phone: item.phone,
        num: item.num
      }
      this.modalShow = true;
    },
    // 提交修改信息
    submitFun() {
      this.$refs["formEle"].validate(valid => {
        if (valid) {
          this.btnLoading = true;
          this.httpPost(this.API.API_takeOrderEdit, this.addFather)
            .then(res => {
              this.$Message.success("编辑成功!");
              this.btnLoading = false;
              this.modalShow = false;
              this.$emit('apiSuccess');
            })
            .catch(err => {
              this.btnLoading = false;
              console.error(err);
            });
        } else {
          this.$Message.error("请输入必填信息!");
        }
      });
    },
    toPageFun(item, index) {
      this.$router.push(item.path);
    }
  }
};
</script>
<style lang="less" scoped>
@import "~@/assets/styles/main.less";
@deep: ~">>>";

::v-deep .ivu-modal-header {
  background-image: url("~@/assets/images/modal_back500.png") !important;
}
.billOrder_styl {
  width: 100%;
}
.modal_styl {
  position: relative;
  padding-bottom: 50px;
}
.title_styl {
  color: #000000;
  border-left: 3px solid @themeColor;
  position: relative;
  padding-left: 10px;

  &::after {
    content: "";
    width: 2px;
    height: 12px;
    position: absolute;
    left: 0;
    top: 4px;
  }
}
.formInfo {
  margin: 10px 0 30px 0;

  .ivu-form-item {
    margin-bottom: 0;
    border-top: #e8eaec 1px solid;
    @{deep} label {
      padding-left: 5px;
      border-right: 1px #e8eaec solid;
      background-color: #f8f8f9;
    }
    @{deep} .ivu-form-item-content {
      padding-left: 8px;
      padding-right: 8px;
      white-space: nowrap;
    }
  }

  @{deep} .overHeight label {
    height: 65px;
  }
  @{deep} .overHeight .ivu-form-item-content {
    height: 65px;
  }
  @{deep} .overHeightMap label {
    height: 150px;
  }
  @{deep} .overHeightMap .ivu-form-item-content {
    height: 150px;
  }
}
.blueColor {
  color: #52a0f3;
}
.blueLine {
  border: 3px #52a0f3 solid;
}
.grayLine {
  border: 3px #f2f2f2 solid;
}
.borderLeft {
  border-left: #e8eaec 1px solid;
}
.borderRight {
  border-right: #e8eaec 1px solid;
}
.borderBottom {
  border-bottom: #e8eaec 1px solid;
}
.borderTop {
  border-top: #e8eaec 1px solid;
}
.content-styl {
  width: 100%;

  .ivu-tabs-bar {
    margin-bottom: 0; //去掉tabs的margin
  }
}

.ivu-modal-content {
  border-radius: 12px;
}
/deep/.ivu-modal-body {
  padding: 20px 40px;
}
</style>
